//
//  settingViewController.m
//  giuseppe
//
//  Created by Apple on 15/8/13.
//  Copyright (c) 2015年 GiantUmbrella. All rights reserved.
//

#import "settingViewController.h"
#import "define.h"

@interface settingViewController ()<UITableViewDataSource,UITableViewDelegate>{
   
    UITableView *_settingTableView;
    
    NSArray *_titleArray;

    NSArray *_contentArray;
    
}

@end

@implementation settingViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    self.edgesForExtendedLayout = UIRectEdgeNone;
    
    
    
    //自定义的导航栏
    UIView *navView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, kScreenWidth, 64)];
    navView.backgroundColor = [UIColor whiteColor];
    navView.alpha = 0.90;
    
    UIButton *backButton = [UIButton buttonWithType:UIButtonTypeCustom];
    backButton.frame = CGRectMake(10, 33, 27, 16);
    [backButton setBackgroundImage:[UIImage imageNamed:@"back"] forState:UIControlStateNormal];
    [backButton addTarget:self action:@selector(back) forControlEvents:UIControlEventTouchUpInside];
    UILabel *titleLabel = [[UILabel alloc]initWithFrame:CGRectMake(kScreenWidth/2-50, 20, 100, 40)];
    titleLabel.text = @"设置";
    titleLabel.textAlignment = NSTextAlignmentCenter;
    
    
    [self _initView];
    
    
    [navView addSubview:backButton];
    [navView addSubview:titleLabel];
    
    
    [self.view addSubview:navView];
    
}

- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
}



- (void)_initView{
    
    _settingTableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 64, kScreenWidth, kScreenHeight-64)];
    _settingTableView.rowHeight = 50;
    _settingTableView.delegate = self;
    _settingTableView.dataSource = self;
    
    [self.view addSubview:_settingTableView];
    

}

#pragma mark - UITableView Delegate && DataSource
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    
    return 3;
    
    
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *indentify = @"Cell";
    
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:indentify];
    if (cell == nil) {
        
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:indentify];
        
        _titleArray = @[@"客服",@"检查更新",@"关于我们"];
        _contentArray = @[@"8008208820",@"v1.0.0",@""];
        
        
        UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(30, 15, 100, 20)];
        
        
        UILabel *numberLabel = [[UILabel alloc]initWithFrame:CGRectMake(kScreenWidth-150, 5, 100, 40)];
        
        titleLabel.text = _titleArray[indexPath.row];
        

        numberLabel.text = _contentArray[indexPath.row];
        numberLabel.textColor = [UIColor lightGrayColor];
        [numberLabel setTextAlignment:NSTextAlignmentRight];
        
        
        
        [cell.contentView addSubview:titleLabel];
        [cell.contentView addSubview:numberLabel];

    }
    
    if (indexPath.row != 0) {
        cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    }
    
    if (indexPath.row == 1) {
        UIImageView *redPointImageView = [[UIImageView alloc]initWithFrame:CGRectMake(100, 10, 8, 8)];
        redPointImageView.backgroundColor = [UIColor redColor];
        redPointImageView.layer.masksToBounds = YES;
        redPointImageView.layer.cornerRadius = 4;
        [cell.contentView addSubview:redPointImageView];
    }
    
    return cell;
    
}


- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    
    return _settingTableView.rowHeight;
}


-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    
    
    
}


- (void)back{
    
    [self.navigationController popViewControllerAnimated:YES];
    
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
